# -*- coding: utf-8 -*-            
# @Author : chenliang
# @Time : 2024/12/21 15:52
from datetime import timedelta
#from datetime import datetime
import datetime

class Tool(object):

    # 获取月份
    def generate_months(self,start_year, start_month, end_year, end_month):
        months = []
        current_year, current_month = start_year, start_month
        while (current_year < end_year) or (current_year == end_year and current_month <= end_month):
            months.append(f"{current_year:04d}-{current_month:02d}")
            if current_month == 12:
                current_year += 1
                current_month = 1
            else:
                current_month += 1
        return months

    # 获取当前周日期列表
    def get_current_week(self,day=0):
        fmt = lambda x: datetime.datetime.strftime(x, "%Y-%m-%d")
        today = datetime.date.today()
        monday = today - timedelta(days=today.weekday() + day)
        return [fmt(monday + timedelta(days=i)) for i in range(7)]

if __name__ == '__main__':
    # 获取当前日期
    now = datetime.now()
    end_year, end_month = now.year, now.month
    print(end_year, end_month)
    # 生成从2024年11月到当前月份的列表
    months_list = Tool().generate_months(2024,11, end_year, end_month)
    print(months_list)